package ArryProTest;
//数组初始化和遍历
public class Test01 {
    public static void main(String[] args) {
        //数组的定义和初始化
//        int[] arr1 = null;
        //默认初始化：数组元素相当于对象的属性，遵守对象的属性默认初始化的规则
        int[ ] arr1 = new int[5];
        //动态初始化：根据索引直接赋值
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        //静态初始化
        int arr2[] = {20,30,40};
        System.out.println(arr2.toString());

        //数组的遍历
        for (int i = 0 ; i<arr1.length;i++){
            arr1[i] = i*2 +1;
        }
        //数组的长度是5，索引范围[o,length-1]
        for (int i = 0 ; i<arr1.length;i++){
            System.out.println(arr1[i]);
        }

    }
}
